//
//  SMGlobalMethod.h
//  Smios
//
//  Created by hao on 15/11/27.
//  Copyright (c) 2015年 sanmi. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CommonCrypto/CommonDigest.h>
#import <CommonCrypto/CommonCryptor.h>
#import "IMYWebView.h"

@interface SMGlobalMethod : NSObject
//date转时间yyyyMMdd
+(NSString *)getTimeFromTimeDaY:(NSDate *)date;
//时间戳转时间
+(NSString *)getTimeFromTimeSp:(NSString *)timeSp;
//时间戳转时间
+(NSString *)getTimeFromShortTimeSpY:(NSString *)shortTimeSp;
//时间戳转时间yyyy-MM-dd
+(NSString *)getTimeFromShortTimeSp:(NSString *)shortTimeSp;
//date转时间
+(NSString *)getTimeFromTimeDa:(NSDate *)date;
+(NSString *)getTimeFromShortTimeDa:(NSDate *)date;
//时间文本转dateShort
+(NSDate *)getTimeDateFromeShortTimeStryy:(NSString *)timeStr;
//将时间转为时间戳
//+ (NSString *)getTimetroWith:
//获取当前时间戳
+(NSString *)getTimeSp;

//获取当前时间 格式 YYYY年MM月dd日 HH:mm
+(NSString *)getcurrenTime;

//当天 最晚时间 XXXX-XX-XX 23:59
+(NSString *)gettomorrowTime:(NSString *)startTime;

//时间文本转date
+(NSDate *)getTimeDateFromeTimeStr:(NSString *)timeStr;
+(NSDate *)getTimeDateFromeShortTimeStr:(NSString *)timeStr;
//date转时间戳
+(NSString *)getTimeSpFromeTimeDate:(NSDate *)date;
//时间文本转date(YYYYMMddHHmm)
+ (NSDate *)getTimeDateFromeTimeStrWithYYY:(NSString *)timeStr;
//date转时间yyyyMMddHHmm
+(NSString *)getTimeFromTimeDaYY:(NSDate *)date;
//13位的时间戳转换
+(NSString *)getTimeFrom13TimeSp:(NSString *)timeSp;

//获取当前系统的日期和时间（24时制）
+(NSString *)getTimeWithTwentyFourStyle;

//获取当前 月 周 日 时间
+(NSString *)getWeekTimeWithdate:(NSDate *)currenDate;

//yyyy-mm-dd转化为yyyy年mm月dd日
+(NSString *)dateFormatter:(NSString*)strDate;
//日期的比较
+(int)compareDate:(NSString*)startdate withDate:(NSString*)enddate AndFomatterType:(NSString *)fomatterType;
//自动消失的提示框
+(void)showMessage:(NSString *)message;
+ (void)showViewCenterWithMessage:(NSString *)message;
#pragma mark-- 正则判断
//邮箱验证
+ (BOOL) validateEmail:(NSString *)email;
//手机号码验证
+ (BOOL) validateMobile:(NSString *)mobile;
//电话号验证
+ (BOOL)validateIsMobileNumber:(NSString *)mobileNum;
//车牌号验证
+ (BOOL) validateCarNo:(NSString *)carNo;
//车型
+ (BOOL) validateCarType:(NSString *)CarType;
//用户名
+ (BOOL) validateUserName:(NSString *)name;
//账户
+(BOOL)validateAccount:(NSString*)account;
//密码
+ (BOOL) validatePassword:(NSString *)passWord;
//昵称
+ (BOOL) validateNickname:(NSString *)nickname;
//身份证号
+ (BOOL) validateIdentityCard: (NSString *)identityCard;
//邮编
+(BOOL) validateZipcode:(NSString *)zipcode;
//获取银行名称
+(NSString *)returnBankName:(NSString*) idCard;


#pragma mark- 各类型数据转换
//data转字典
+(NSDictionary*)returnDictionaryWithDataPath:(NSData*)data;
//字典转data
+(NSData*)returnDataWithDictionary:(NSDictionary*)dict;
//字典转json串
+(NSString*)returnDictionaryToJson:(NSDictionary *)dic;

#pragma mark-- 清理缓存
//计算单个文件大小
+(float)fileSizeAtPath:(NSString *)path;
//计算目录大小
+(float)folderSizeAtPath:(NSString *)path;
//清理缓存
+(void)clearCache:(NSString *)path;
#pragma mark 压缩图片
+(UIImage*)imageWithImage:(UIImage*)image;
//判断是不是数字

+(BOOL)isPureNumandCharacters:(NSString *)string;

+(CGFloat)heightWithWebView:(IMYWebView *)webView;

#pragma 获取手机ip地址

+(NSString *)getDeviceIPIpAddresses;

#pragma mark- 加密算法 des
+(NSString *) encryptUseDES:(NSDictionary *)dic key:(NSString *)key;
#pragma mark - 解密 des
+(NSString *)decryptUseDES:(NSString  *)cipherText key:(NSString *)key;

//保存图片到本地
+(void)saveImage:(UIImage *)currentImage withName:(NSString *)imageName;
//从本地数据库获取图片
+(UIImage *)getImageFromDocumentwithFile:(NSString *)file;

//根据key值 读写信息
+(void)writeMessageWithDataDic:(id)message AndKey:(NSString *)key;
+(id)readMessageKey:(NSString *)key;

+(void)removeMessageWithKey:(NSString *)key;

//存储用户信息
+(void)writeUserMessageWithUserDic:(id)content;
//读取用户信息
+(id)readUserMessage;

//删除登录信息
+(void)removeUserMessage;

+(void)savaLoginstatusWithStatus:(BOOL)status;
+(BOOL)readLoginstatus;

//拨打电话
+(void)telephoneForAppWithNum:(NSString *)telephone;

+(NSString *)getPreferredLanguage;

+(NSMutableAttributedString *)atrbutestringWithcontentStr:(NSString *)contentString Andrange:(NSRange)range Andcolor:(UIColor *)atrbuteColor Andfont:(UIFont *)atrbuteFont;


/**
  取消  image的渲染效果
  
  @param image image
  @return image
  */
+(UIImage *)cancelRenderingMode:(UIImage *)image;


+(void)PushLoginViewControllerWithsuccessBlcok:(void (^)(void))successBlock;

+(void)prensentViewLoginControllerWithsuccessBlcok:(void (^)(void))successBlock;


//查看大图
+(void)showPhotosWithsuperVC:(UIViewController *)superVC AndSuperViews:(NSArray<UIImageView *>*)superImageViews AndselectIndex:(NSInteger)index;

+(void)showPhotosWithImgUrls:(NSArray *)urls AndselectIndex:(NSInteger)index;

//获取视频第一帧图片 //卡
+(NSData *)getVideoPreViewImage:(NSString *)filePath;


+ (UIViewController *)getCurrentVC;

+(void)timeCuterWithSuper:(UIButton *)codeBtn AndoverBlock:(void (^)(void))runLoperBlock;

+(NSString*)handleNullString:(id)m_result;

@end

